package cn.hairui.blog.controller.manage;

import cn.hairui.blog.constant.PubConstant;
import cn.hairui.blog.model.WebInfo;
import cn.hairui.blog.model.manage.MgrResc;
import cn.hairui.blog.service.WebInfoService;
import cn.hairui.blog.service.manage.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author lihairui
 * @version V1.0
 * @date: 2019/8/4 0:33
 */
@Controller
@RequestMapping("/manage")
public class DefaultViewManageController {

    @Autowired
    private WebInfoService webInfoService;
    @Autowired
    private ResourceService resourceService;

    @RequestMapping(value = "/logout")
    public String logout(HttpServletRequest request) {
        HttpSession session = request.getSession();
        session.invalidate();
        return "redirect:/";
    }

    @RequestMapping(value = "/index")
    public String manageIndex(HttpServletRequest request, Model model) {
        WebInfo webInfo = webInfoService.find(PubConstant.MY_INFO_ID);
        model.addAttribute("webinfo", webInfo);
        List<MgrResc> mgrRescList = resourceService.listRescMgrShow();
        model.addAttribute("mgrRescs", mgrRescList);
        return "manage/index";
    }

    @RequestMapping(value = "/main")
    public String main() {
        return "manage/page/main";
    }


    //以上为例子中的内容
    @RequestMapping(value = "/page/news/newsList")
    public String newsList() {
        return "manage/page/news/newsList";
    }

    @RequestMapping(value = "/page/img/images")
    public String images() {
        return "manage/page/img/images";
    }

    @RequestMapping(value = "/page/404")
    public String page404() {
        return "manage/page/404";
    }

    @RequestMapping(value = "/page/login/login")
    public String login() {
        return "manage/page/login/login";
    }

    @RequestMapping(value = "page/user/userList")
    public String userList() {
        return "manage/page/user/userList";
    }

    @RequestMapping(value = "page/user/userGrade")
    public String userGrade() {
        return "manage/page/user/userGrade";
    }

    @RequestMapping(value = "page/systemSetting/basicParameter")
    public String basicParameter() {
        return "manage/page/systemSetting/basicParameter";
    }

    @RequestMapping(value = "page/systemSetting/logs")
    public String logs() {
        return "manage/page/systemSetting/logs";
    }

    @RequestMapping(value = "page/systemSetting/linkList")
    public String linkList() {
        return "manage/page/systemSetting/linkList";
    }

    @RequestMapping(value = "page/systemSetting/icons")
    public String icons() {
        return "manage/page/systemSetting/icons";
    }

    @RequestMapping(value = "page/doc/addressDoc")
    public String addressDoc() {
        return "manage/page/doc/addressDoc";
    }

    @RequestMapping(value = "page/doc/bodyTabDoc")
    public String bodyTabDoc() {
        return "manage/page/doc/bodyTabDoc";
    }

    @RequestMapping(value = "page/doc/navDoc")
    public String navDoc() {
        return "manage/page/doc/navDoc";
    }


}
